<?php
namespace WechatSDK\Components;

/**
 * 调度,发送接收者调度、由接收，发送消息共用
 * @author guibinyu
 * @date 2017-06-15 04:14:50
 */

class Dispatcher
{
    private static $fromUserName='';
    private static $toUserName='';
    private static $_instance = null;
    
    static public function getInstance() {
        if (is_null ( self::$_instance ) || isset ( self::$_instance )) {
            self::$_instance = new self ();
        }
        return self::$_instance;
    }
    /**
     * 
     * @param type $receive
     */
    public function forward($receive)
    {
        self::$fromUserName = isset($receive['FromUserName']) ? $receive['FromUserName']: '';
        self::$toUserName = isset($receive['ToUserName']) ? $receive['ToUserName']: '';
    }
    /**
     * 获取消息发送者，以微信用户第一人称
     * @return type
     */
    public function getReceiveFrom() 
    {
        return self::$fromUserName;
    }
    /**
     * 消息接收者，以微信用户第一人称
     * @return type
     */
    public function getReceiveTo() 
    {
        return self::$toUserName;
    }
}
?>